<template>
  <div class="execution">
    <basic-container>
      <div class="table-container">
        <el-table
          border
          :data="list"
          :header-cell-style="{ color: '#4D4D4D', background: '#fafafa' }">
          <el-table-column label="商家名称" align="center" prop="name"></el-table-column>
          <el-table-column
            label="店铺头像"
            align="center">
            <template slot-scope="scope">
              <img :src="scope.row.icon" style="width: 100px;height: 100px;" />
            </template>
          </el-table-column>
          <el-table-column
            label="联系人名字"
            align="center"
            prop="contactName"
          ></el-table-column>
          <el-table-column
            label="联系人电话"
            align="center"
            prop="contactPhone"
          ></el-table-column>
          <el-table-column
            label="联系人邮箱"
            align="center"
            prop="contactEmail"
          ></el-table-column>
          <el-table-column label="操作" align="center">
            <template slot-scope="scope">
              <el-button
                size="small"
                @click="handleDetails(scope.$index, scope.row)"
                type="text">审核</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </basic-container>


    <el-dialog
      title="审核"
      :visible.sync="dialogVisible"
      width="80%">
      <div class="info-main">
        <ul class="info-desc-list">
          <li class="info-desc-item">
            <label>店铺名称： </label>
            <span>{{ form.name }}</span>
          </li>
          <li class="info-desc-item">
            <label>联系人姓名: </label>
            <span>{{ form.contactName }}</span>
            <label style="min-width: 10em">联系人手机：</label>
            <span>{{ form.contactPhone }}</span>
            <label style="min-width: 10em">联系人邮箱：</label>
            <span>{{ form.contactEmail }}</span>
          </li>
          <li class="info-desc-item">
            <label>身份证姓名： </label>
            <span>{{ form.cardName }}</span>
            <label style="min-width: 10em">身份证号：</label>
            <span>{{ form.cardId }}</span>
          </li>
          <li class="info-desc-item">
            <label>身份证正面： </label>
            <img :src="form.cardUrlPositive" class="imgIcon" />
            <label style="min-width: 10em">身份证反面：</label>
            <img :src="form.cardUrlTos" class="imgIcon" />
          </li>
          <li class="info-desc-item">
            <label>企业名称： </label>
            <span>{{ form.companyName }}</span>
            <label style="min-width: 10em">企业地址：</label>
            <span>{{ form.province }}{{ form.addressProvince }}</span>
            <label style="min-width: 10em">统一信用代码：</label>
            <span>{{ form.creditId }}</span>
          </li>
          <li class="info-desc-item">
            <label>营业执照： </label>
            <img :src="form.creditUrl" class="imgIcon" />
          </li>
          <li class="info-desc-item">
            <el-input
              style="width: 85%; padding-left: 6%"
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 4 }"
              placeholder="请输入内容"
              v-model="textarea"
            >
            </el-input>
          </li>
        </ul>
      </div>
      <div class="info-button">
        <el-button
          type="info"
          plain
          @click="handleNo"
          >不通过</el-button
        >
        <el-button
          type="primary"
          plain
          @click="handleAdopt"
          >通过</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import "@/styles/index.scss";
  import { secondAuditList, secondAudit } from "@/api/rms/rmsstore";

  export default {
    data() {
      return {
        list: [],
        dialogVisible:false,
        form: {},
        textarea: null
      }
    },
    created() {
      this.getList()
    },
    methods: {
      getList() {
        secondAuditList().then(res => {
          this.list = res.data.data
        })
      },
      handleDetails(index,row) {
        this.dialogVisible = true
        this.form = Object.assign({}, row)
      },
      handleNo() {
        if (!this.textarea) {
        this.$message.warning("请填写不通过原因！");
        return;
      }

      let params = {
        storeId: this.form.id,
        status: 4,
        message: this.textarea,
      };

      secondAudit(params).then((res) => {
        if (res.data.code === 200) {
          this.$message({
            type: "success",
            message: res.data.msg,
            duration: 1000,
          });
          this.getList()
        } else {
          this.$message({
            type: "warning",
            message: res.data.msg,
            duration: 1000,
          });
        }
      });
      },
      handleAdopt() {
        let params = {
          storeId: this.form.id,
          status: 1
        };
        adoptProduct(param).then((res) => {
        if (res.data.code === 200) {
          this.$message({
            type: "success",
            message: res.data.msg,
            duration: 1000,
          });
          this.getList()
        } else {
          this.$message({
            type: "warning",
            message: res.data.msg,
            duration: 1000,
          });
        }
      });
      }
    }
  }
</script>
